<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">

    <title>Zero-X 管理系统 - 登录</title>
    <link rel="shortcut icon" href="${pageContext.request.contextPath}/statics/images/ico/favicon.ico"/>
    <link href="${pageContext.request.contextPath}/statics/css/bootstrap.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/statics/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/statics/css/animate.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/statics/css/style.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/statics/css/login.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/statics/layui/css/layui.css" rel="stylesheet">
    <script src="${pageContext.request.contextPath}/statics/layui/layui.js"></script>
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html"/>
    <![endif]-->
    <script>
        if (window.top !== window.self) {
            window.top.location = window.location;
        }
    </script>

</head>

<body class="signin">
<div class="signinpanel">
    <div class="row">
        <div class="col-sm-7">
            <div class="signin-info">
                <div class="logopanel m-b">
                    <h4>欢迎来到<h1>[ Zero-X 管理系统 ]</h1></h4>
                </div>
                <div class="m-b"></div>
                <strong>还没有账号？ <a href="#">立即注册&raquo;</a></strong>
            </div>
        </div>
        <div class="col-sm-5">
            <form  lay-filter="formLogin" class="layui-form">
                <h4 class="no-margins">登录：</h4>
                <input type="text" name="loginName" class="form-control uname" placeholder="用户名"/>
                <input type="password" id="password" name="password" class="form-control pword" placeholder="密码"/>
                <div class="input-group m-t m-b">
                    <input type="text" name="randomCode" id="randomCode" class="form-control no-margins"
                           placeholder="验证码" style="color: black">
                    <span class="input-group-addon no-padding">
                        <img src="${pageContext.request.contextPath}/checkCode" alt="" width="100" height="32"
                             class="passcode" style="height:32px;cursor:pointer;" onclick="this.src=this.src+'?'">
                    </span>
                </div>
                <a href="">忘记密码了？</a>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="signup-footer">
        <div class="pull-left">
            &copy; 2022 All Rights Reserved. Zero-X 管理系统
        </div>
    </div>
</div>
</body>
<script>
    layui.use(['form', 'jquery', 'laydate'], function (data) {
        var form = layui.form;
        var $ = layui.jquery;
        var laydate = layui.laydate;
        // 发送Ajax请求
        //提交事件
        form.on('submit(demo1)', function(data){
            // alert(JSON.stringify(data.field), {
            //     title: '最终的提交信息'
            // })
            $.get({
                url: 'login2',
                data: data.field,
                dataType: "text",
                success: function (data) {
                    if (data === 'success') {
                        layer.msg('登录成功', {
                            time: 1000
                        }, function () {
                            window.location.href = '${pageContext.request.contextPath}/toHome';
                        });
                    } else if (data === "yzm") {
                        layer.msg('请输入正确的验证码', function () {
                        });
                    } else {
                        layer.msg('用户名或密码错误', function () {
                        });

                    }
                }
            })
            return false;
        });
    })
</script>
</html>
